#!/usr/bin/python

notes = {
'A': '0 12- ---- (thumb, first and second finger of left hand) ',
'B': '0 1-- ----',
'C': '0 123 4567',
"C'": '0 -2- ---- (thumb, second finger of left hand) ',
'D': '0 123 456-',
"D'": '- -2- ---- (just the second finger of left hand) ',
'E': '0 123 45-- (all left-hand holes, right first and second finger) ',
'F': '0 123 4-67',
'F#': '0 123 -56-',
'G': '0 123 ---- (thumb, first, second, third finger of left hand) ',
}

songs = (
  ('Mary had a little lamb / Merrily we roll along',
   "B A G A B B B, A A A, B D' D', B A G A B B B, A A B A G"),
  ('Oh when the Saints',
   "G B C' D', G B C' D', G B C' D' B G B A, "
   "B B A G G B D' D' C', B C' D' B G A G"),
  ('Twinkle Twinkle little star',
   "D D A A B B A, G G F# F# E E D"),
  ('Oh Susanna',
   "D E F# A A B A F# D E F# F# E D E"),
  ('Happy Birthday',
   "D D E D G F#, D D E D A G, D D D' B G F# E, C' C' B G A G"),
  ('Believe Me if All Those Endearing Young Charms',
   "E D C D C C E G F A C' C'"),
  ('Scotland the Brave',
   "C C D E C E G C' C' C' C' G E C F A F"),
  ('Auld Lang Syne',
   "C F F F A G F G A F F A C' D'"),
  ('Hot Cross Buns',
   "B A G - | B A G - | G G G G A A A A | B A G - ||"),
  ('French Folk Song',
   "G G G A | B - A - | G B A A | G - - - :||"),
  ('Mary Had A Little Lamb',
   "B A G A | B B B - | A A A - | B B B - | "
   "B A G A | B B B - | A A B A | G - - - ||"),
  ('Meet Captain C',
   "B B C C | B B A - | B B C C | B - A - | "
   "B B C C | B B A - | G G A A | G - G - ||"),
  ('Flying High',
   "C C C C | B B B B | A A A A | G - - - | "
   "C B A G | C B A G | C B A A | G G G - ||"),
  ('Little Robin Red Breast',
   "G G G G | A - A - | B B B B | C - - - | "
   "D D D D | C C C C | B B A A | G - - - ||"),
  ('Aura Lee',
   "G C B C | D A D - | C B A B | C - G - | "
   "G C B C | D A D - | C B A B | C - - - ||"),
  ('Ode To Joy',
   "B B C D | D C B A | G G A B | B A A - | "
   "B B C D | D C B A | G G A B | A G G - ||"),
  ('The Lion Sleeps Tonight',
   "G A B A B | C B A G A | B A G B | A - - - | "
   "D B A B D | C B A G A | B A G B | A - - - ||"),
  ('Jingle Bells',
   "B B B - | B B B - | B D G A | B - - - | "
   "C C C C | C B B B B | B A A B | A - D - | "
   "B B B - | B B B - | B D G A | B - - - | "
   "C C C C | C B B B B | D D C A | G - - - ||"),
  ('Lightly Row (Part A)',
   "D B B - | C A A - | G A B C | D D D - | "
   "D B B - | C A A - | G B D D | B - - - ||"),
  ('Lightly Row (Part B)',
   "B G G - | A F# F# - | G F# G A | B B B - | "
   "B G G - | A F# F# - | G G F# F# | G - - - ||"),
  ('Sweetly Sings The Donkey',
   "G F# G A | B - B - | A G A B | G - - - | "
   "B A B C | D - D - | C B C D | G (spoken: 'Hee Haw!') - ||"),
  ('My Dreidl',
   "D | G G A A | B G - B | D D C B | A - - D | "
   "A A B B | C A - A | D C B A | G - - B | "
   "D B D B | D B - B | D D C B | A - - A | "
   "C A C A | C A - A | D C B A | G - - ||"),
  ('When The Saints Go Marching In',
   "- G B C | D - - - | - G B C | D - - - | - G B C | "
   "D - B - | G - B - | A - - - | - - B A | G - - G | "
   "B - D D | D C - - | - - B C | D - B - | G - A - | G - - - ||"),
  ('Jolly Old St. Nicholas',
   "B B B B | A A A - | G G G G | B - - - | "
   "lowE lowE lowE lowE | lowD lowD  G - | A G A B | A - - - | "
   "B B B B | A A A - | G G G G | B - - - | "
   "lowE lowE lowE lowE | lowD lowD  G - | A G A B | G - - - ||"),
  ('Ode To Joy (Complete)',
   "B B C D | D C B A | G G A B | B A A - | "
   "B B C D | D C B A | G G A B | A G G - | "
   "A A B G | A BC B G | A BC B A | G A lowD - | "
   "B B C D | D C B A | G G A B | A G G - ||"),
  ('Twinkle, Twinkle Little Star',
   "G G D D | highE highE D - | C C B B | A A G - | "
   "D D C C | B B A - | D D C C | B B A - | "
   "G G D D | highE highE D - | C C B B | A A G - ||"),
  ('We Three Kings',
   "B - A | G - lowE | F# G F# | lowE - - | "
   "B - A | G - lowE | F# G F# | lowE - - | "
   "G - G | A - A | B - B | D C B | "
   "A B A | G - F# | lowE - - ||"),
  ('Good King Wenceslas',
   "G G G A | G G lowD - | lowE lowD lowE F# | G - G - | "
   "G G G A | G G lowD - | lowE lowD lowE F# | G - G - | "
   "D C B A | B A G - | lowE lowD lowE F# | G - G - | "
   "lowD lowD lowE F# | G G A - | D C B A | G - C - | G - - - ||"),
  ('Yankee Doodle',
   "G G A B | G B A lowD | G G A B | G - F# | "
   "G G A B | C B A G | F# lowD lowE F# | G - G - | "
   "lowE F# lowE lowD | lowE F# G - | D highE D C | B - D - | "
   "lowE F# lowE lowD | lowE F# G lowE | lowD G F# A | G - G - ||"),
  ("Papageno'S Song (From The Magic Flute)",
   "B A | G G A G F# G | A B A - A F# | lowD lowD D - D B A G - "
   "B | A G F# G A G F# G | A B A - A | D - D A A | F# lowE lowD "
   "lowD F# | A A B A G A | B A G D | F# F# A G F# G | A B A - | "
   "G A | B - B C B A B | C D highE C A | F# - F# G F# E F# | G A F# "
   "G - - ||"),
  ("Lord of the rings: From the shire",
   "C D E G E D E D C E G A C highB G E F E D C D E G E D E D C E G A G G "
   "E E F E D C D C"),
  ("Frosty the snowmay",
   "G  E  F G highC  B C highD C B A G "
   "B C highD C B AA G highC E "
   "(1st_Time) G A G  F lowE  F  G (D.C._=Back_to_the_beginning) "
   "(2nd Time) G A G  F lowE lowD lowC")
  )

def FindSong(x):
  print '\n'
  while True:
    x = raw_input(' Choose a Song: ')
    if not x:
      return None
    try:
      return int(x)
    except:
      pass
    for i in range(0, len(songs)):
      if x.lower() in songs[i][0].lower():
        return i




def Main():

  while True:
    for x in range(0, len(songs)):
      print '%2d: %s' % (x, songs[x][0])
    x = FindSong(x)
    if x is None:
      break
    print '\n%d: %s\n%s\n' % (x, songs[x][0], songs[x][1])
    count = 0
    for x in songs[x][1].split():
      extra_newline = x.endswith(',')
      pre = ''
      post = ''
      if extra_newline:
        x = x.strip(',')
        post = '\n'
      if x.startswith('low'):
        pre = 'low '
        x = x[3:]
      if x.startswith('high'):
        pre = 'high '
        x = x[4:]
      print '%-2s: %5s%s%s' % (x, pre, notes.get(x, x), post)
      if extra_newline:
        print ''
      count += 1
      if count % 25 == 0:
        raw_input('\nhit enter for the rest...')

    raw_input('\nhit enter to play another song')

if __name__ == '__main__':
  Main()

